package com.fin.zw.intelligentbot.entity;


import com.fin.zw.intelligentbot.enums.SourceType;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

@Entity
@Table(appliesTo = "ai_account",comment = "ai语音账号管理")
@Data
public class AiAccount extends BaseEntity{

    @Column(columnDefinition = "varchar(100) COMMENT '身份认证'")
    private String token;

    @Column(columnDefinition = "varchar(50) COMMENT '名称'")
    private String name;

    @Column(columnDefinition = "varchar(50) COMMENT '账号'")
    private String account;

    @Column(name = "password",columnDefinition = "varchar(100) COMMENT '密码'")
    private String pwd;

    @Column(columnDefinition = "varchar(20) COMMENT '来源'")
    @Enumerated(EnumType.STRING)
    private SourceType source;

    @Column(name = "auth_type",columnDefinition = "varchar(10) COMMENT '身份验证方式'")
    private String authType = "Token";

    @Column(columnDefinition = "datetime COMMENT '最后获取token时间'")
    private Date lastTokenTime;

    @Column(columnDefinition = "varchar(200) COMMENT 'url路径'")
    private String url;

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(name = "ai_account_company", joinColumns = @JoinColumn(name = "account_id"), inverseJoinColumns = @JoinColumn(name = "company_id"))
    private Set<Company> companies;
}
